package com.faithbj.dao.impl;

import java.util.List;

import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import com.faithbj.common.dao.impl.BaseDaoImpl;
import com.faithbj.common.model.fm.FamilyMember;
import com.faithbj.dao.FamilyMemberDao;

@Repository("familyMemberDao")
public class FamilyMemberDaoImpl extends BaseDaoImpl<FamilyMember, String>
		implements FamilyMemberDao {

	@Override
	public Long getMemberNumByApplyIds(String[] applyIds) {
		// TODO Auto-generated method stub
		String hql = "select count(fm) from FamilyMember fm "
				+ "where fm.checkTotal.id in(:applyIds)";
		return (Long) getSession().createQuery(hql)
				.setParameterList("applyIds", applyIds).uniqueResult();
	}

	@Override
	public List<FamilyMember> getFamilyMembersByCheckTotal(final String ctId) {
		Session session = this.getSession();
		return session.createCriteria(FamilyMember.class)
				.add(Restrictions.eq("checkTotal.id", ctId)).list();
	}

}
